using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;

namespace WbsEditor
{
    public partial class ColorPickerButton : System.Windows.Forms.Button
    {
        public ColorPickerButton()
        {
            InitializeComponent();
        }

        public ColorPickerButton(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }

        private System.Drawing.Color _color;
        [Browsable(true), Category("Appearance")]
        public System.Drawing.Color Color
        {
            get
            {
                return _color;
            }

            set
            {
                _color = value;
                BackColor = value;
            }
        }

        protected override void OnClick(EventArgs e)
        {
            ColorDialog colorDialog = new ColorDialog();
            colorDialog.Color = Color;
            DialogResult res = colorDialog.ShowDialog(this);
            if (DialogResult.OK == res)
            {
                Color = colorDialog.Color;
            }

            base.OnClick(e);
        }
    }
}
